package it.davial.mgwt.client.ui.widget.search_form;

import it.davial.mgwt.client.ui.widget.base.HasSearchForm;

import java.util.Date;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.datepicker.client.DateBox;
import com.googlecode.mgwt.ui.client.MGWTStyle;
import com.googlecode.mgwt.ui.client.widget.FormListEntry;
import com.googlecode.mgwt.ui.client.widget.MTextBox;
import com.googlecode.mgwt.ui.client.widget.WidgetList;

public class SearchForm extends Composite implements HasSearchForm{
	private FlowPanel container;
	private HTML title;
	private WidgetList panel;
	private MTextBox surname ;
	private DateBox date;
	
	public SearchForm(){
		container = new FlowPanel();
		title = new HTML("Ricerca");
		title.addStyleName(MGWTStyle.getTheme().getMGWTClientBundle().getListCss().listHeader());
		container.add(title);
		panel = new WidgetList();
		panel.setRound(true);
		surname = new MTextBox();
		date = new DateBox();
		//date.setFormat("dd/MM/yyyy");
		panel.add(new FormListEntry("Cognome", surname));
		panel.add(new FormListEntry("Data nascita", date));
		container.add(panel);
		initWidget(container);
	}

	@Override
	public Widget asWidget() {
		return container.asWidget();
	}
	
	@Override
	public String getSurname(){
		return surname.getValue();
	}
	@Override
	public Date getDate(){
		return date.getValue();
	}

}
